home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 November: Tool Chest / Dev.CD Nov 00 TC Disk 2.toast / pc / sample code / overview / testylesample / testylesample.h < prev    next >
Encoding:
Text File  |  2000-09-28  |  10.4 KB  |  262 lines

  1. /*------------------------------------------------------------------------------
  2. #
  3. #    Apple Macintosh Developer Technical Support
  4. #
  5. #    MultiFinder-Aware Styled TextEdit Sample Application
  6. #
  7. #    TEStyleSample
  8. #
  9. #    TEStyleSample.h    -    Rez Source
  10. #
  11. #    Copyright © 1989 Apple Computer, Inc.
  12. #    All rights reserved.
  13. #
  14. #    Versions:    1.0                        10/89
  15. #
  16. #    Components:    TEStyleSample.p            October    1, 1989
  17. #                TEStyleSampleGlue.a        October    1, 1989
  18. #                TEStyleSample.r            October    1, 1989
  19. #                TEStyleSample.h            October    1, 1989
  20. #                PTEStyleSample.make        October    1, 1989
  21. #
  22. #    TEStyleSample is an example application that demonstrates how 
  23. #    to initialize the commonly used toolbox managers, operate 
  24. #    successfully under MultiFinder, handle desk accessories and 
  25. #    create, grow, and zoom windows. Both styled and fundamental TextEdit 
  26. #    toolbox calls and TextEdit autoscroll are demonstrated. It 
  27. #    also shows how to create and maintain scrollbar controls as well
  28. #    as implementing a basic printing loop.
  29. #
  30. #    It does not by any means demonstrate all the techniques you 
  31. #    need for a large application. In particular, TEStyleSample does not 
  32. #    cover exception handling, multiple windows/documents, 
  33. #    sophisticated memory management, or undo. All of 
  34. #    these are vital parts of a normal full-sized application.
  35. #
  36. #    This application is an example of the form of a Macintosh 
  37. #    application; it is NOT a template. It is NOT intended to be 
  38. #    used as a foundation for the next world-class, best-selling, 
  39. #    600K application. A stick figure drawing of the human body may 
  40. #    be a good example of the form for a painting, but that does not 
  41. #    mean it should be used as the basis for the next Mona Lisa.
  42. #
  43. #    We recommend that you review this program, TESample or Sample before 
  44. #    beginning a new application. TESample is a simpler version of TEStyleSample
  45. #    without styles and Sample is a simple app. which doesn’t 
  46. #    use TextEdit or the Control Manager.
  47. #
  48. ------------------------------------------------------------------------------*/
  49.  
  50. /*    These #defines correspond to values in the Pascal source code.
  51.     TEStyleSample.c and TEStyleSample.r include this file. */
  52.  
  53. /*    Determining an application's minimum size to request from MultiFinder depends
  54.     on many things, each of which can be unique to an application's function,
  55.     the anticipated environment, the developer's attitude of what constitutes
  56.     reasonable functionality and performance, etc. Here is a list of some things to
  57.     consider when determining the minimum size (and preferred size) for your
  58.     application. The list is pretty much in order of importance, but by no means
  59.     complete.
  60.     
  61.     1.    What is the minimum size needed to give almost 100 percent assurance
  62.         that the application won't crash because it ran out of memory? This
  63.         includes not only things that you do have direct control over such as
  64.         checking for NIL handles and pointers, but also things that some
  65.         feel are not so much under their control such as QuickDraw and the
  66.         Segment Loader.
  67.         
  68.     2.    What kind of performance can a user expect from the application when
  69.         it is running in the minimum memory configuration? Performance includes
  70.         not only speed in handling data, but also things like how many documents
  71.         can be opened, etc.
  72.         
  73.     3.    What are the typical sizes of scraps is [a boy dog] that a user might
  74.         wish to work with when lauching or switching to your application? If
  75.         the amount of memory is too small, the scrap may get lost [will have
  76.         to be shot]. This can be quite frustrating to the user.
  77.         
  78.     4.    The previous items have concentrated on topics that tend to cause an
  79.         increase in the minimum size to request from MultiFinder. On the flip
  80.         side, however, should be the consideration of what environments the
  81.         application may be running in. There may be a high probability that
  82.         many users with relatively small memory configurations will want to
  83.         avail themselves of your application. Or, many users might want to use it
  84.         while several other, possibly related/complementary applications are
  85.         running. If that is the case, it would be helpful to have a fairly
  86.         small minimum size.
  87.     
  88.     What we did for TEStyleSample:
  89.     
  90.         We determined the smallest heap size that TEStyleSample could have and still
  91.         run (22K). For the preferred size we added enough space to permit:
  92.             a. a maximum size TextEdit text handle (32000 characters)
  93.             b. a maximum usable TextEdit scrap (32000 characters)
  94.             b. a maximum scrap as a result of Copy (32000 characters)
  95.             d. a little performance cushion (see 2, above) (10K)
  96.         Result: 122K for preferred size
  97.         
  98.         For the minimum size we took the 22K and then scaled down our requirements
  99.         for a,b, and c above. We thought that providing 16K more would be lean
  100.         and mean (see 4, above).
  101.         Result: 38K for minimum size
  102. */
  103.  
  104. #define kPrefSize                122
  105. #define kMinSize                38
  106.     
  107. /* The following constants are used to identify menus and their items. The menu IDs
  108.    have an "m" prefix and the item numbers within each menu have an "i" prefix. */
  109. #define    mApple                    128        /* Apple menu */
  110. #define    iAbout                    1
  111.  
  112. #define    mFile                    129        /* File menu */
  113. #define    iNew                    1
  114. #define    iClose                    4
  115. #define    iQuit                    12
  116.  
  117. #define    mEdit                    130        /* Edit menu */
  118. #define    iUndo                    1
  119. #define    iCut                    3
  120. #define    iCopy                    4
  121. #define    iPaste                    5
  122. #define    iClear                    6
  123. #define iSelectAll                8
  124.  
  125. #define mFont                    131        /* Font menu         */
  126.  
  127. #define mFontSize                132        /* Font Size menu     */
  128.  
  129. #define mStyle                    133        /* Style menu         */
  130. #define iPlain                    1
  131. #define iBold                    3
  132. #define iItalic                    4
  133. #define iUnderline                5
  134. #define iOutline                6
  135. #define iShadow                    7
  136.  
  137. /* kTopLeft - This is for positioning the Disk Initialization dialogs. */
  138.  
  139. #define kDITop                    0x0050
  140. #define kDILeft                    0x0070
  141.  
  142. /*    kTextMargin is the number of pixels we leave blank at the edge of the window. */
  143. #define kTextMargin                2
  144.  
  145. /* kMaxOpenDocuments is used to determine whether a new document can be opened
  146.    or created. We keep track of the number of open documents, and disable the
  147.    menu items that create a new document when the maximum is reached. If the
  148.    number of documents falls below the maximum, the items are enabled again. */
  149. #define    kMaxOpenDocuments        1
  150.     
  151. /*    kMaxDocWidth is an arbitrary number used to specify the width of the TERec's
  152.     destination rectangle so that word wrap and horizontal scrolling can be
  153.     demonstrated. */
  154. #define    kMaxDocWidth            576
  155.     
  156. /* kMinDocDim is used to limit the minimum dimension of a window when GrowWindow
  157.     is called. */
  158. #define    kMinDocDim                64
  159.  
  160. /*    kControlInvisible is used to 'turn off' controls (i.e., cause the control not
  161.     to be redrawn as a result of some Control Manager call such as SetCtlValue)
  162.     by being put into the contrlVis field of the record. kControlVisible is used
  163.     the same way to 'turn on' the control. */
  164. #define kControlInvisible        0
  165. #define kControlVisible            0xFF
  166.  
  167. /*    kScrollbarAdjust and kScrollbarWidth are used in calculating
  168.     values for control positioning and sizing. */
  169. #define kScrollbarWidth            16
  170. #define kScrollbarAdjust        (kScrollbarWidth - 1)
  171.  
  172. /*    kScrollTweek compensates for off-by-one requirements of the scrollbars
  173.  to have borders coincide with the growbox. */
  174. #define kScrollTweek            2
  175.     
  176. /*    kCrChar is used to match with a carriage return when calculating the
  177.     number of lines in the TextEdit record. kDelChar is used to check for
  178.     delete in keyDowns. */
  179. #define kCrChar                    13
  180. #define kDelChar                8
  181.     
  182. /*    kButtonScroll is how many pixels to scroll horizontally when the button part
  183.     of the horizontal scrollbar is pressed. */
  184. #define kButtonScroll            4
  185.     
  186. /*    kMaxTELength is an arbitrary number used to limit the length of text in the TERec
  187.     so that various errors won't occur from too many characters in the text. */
  188. #define    kMaxTELength            32000
  189.  
  190. /* kSysEnvironsVersion is passed to SysEnvirons to tell it which version of the
  191.    SysEnvRec we understand. */
  192. #define    kSysEnvironsVersion        1
  193.  
  194. /* kOSEvent is the event number of the suspend/resume and mouse-moved events sent
  195.    by MultiFinder. Once we determine that an event is an OSEvent, we look at the
  196.    high byte of the message sent to determine which kind it is. To differentiate
  197.    suspend and resume events we check the resumeMask bit. */
  198. #define    kOSEvent                app4Evt    /* event used by MultiFinder */
  199. #define    kSuspendResumeMessage    1        /* high byte of suspend/resume event message */
  200. #define    kResumeMask                1        /* bit of message field for resume vs. suspend */
  201. #define    kMouseMovedMessage        0xFA    /* high byte of mouse-moved event message */
  202.  
  203. /* kMinHeap - This is the minimum result from the following
  204.      equation:
  205.             
  206.             ORD(GetApplLimit) - ORD(ApplicZone)
  207.             
  208.      for the application to run. It will insure that enough memory will
  209.      be around for reasonable-sized scraps, FKEYs, etc. to exist with the
  210.      application, and still give the application some 'breathing room'.
  211.      To derive this number, we ran under a MultiFinder partition that was
  212.      our requested minimum size, as given in the 'SIZE' resource. */
  213.      
  214. #define    kMinHeap                 (29 * 1024)
  215.     
  216. /* kMinSpace - This is the minimum result from PurgeSpace, when called
  217.      at initialization time, for the application to run. This number acts
  218.      as a double-check to insure that there really is enough memory for the
  219.      application to run, including what has been taken up already by
  220.      pre-loaded resources, the scrap, code, and other sundry memory blocks. */
  221.      
  222. #define    kMinSpace                (20 * 1024)
  223.  
  224. /*    kExtremeNeg and kExtremePos are used to set up wide open rectangles and regions. */
  225. #define kExtremeNeg                -32768
  226. #define kExtremePos                (32767 - 1) /* required to address an old region bug */
  227.     
  228. /* kTESlop provides some extra security when pre-flighting edit commands. */
  229. #define    kTESlop                    1024
  230.  
  231. /* The following are indicies into STR# resources. */
  232. #define    eWrongMachine            1
  233. #define    eSmallSize                2
  234. #define    eNoMemory                3
  235. #define    eNoSpaceCut                4
  236. #define    eNoCut                    5
  237. #define    eNoCopy                    6
  238. #define    eExceedPaste            7
  239. #define    eNoSpacePaste            8
  240. #define    eNoWindow                9
  241. #define    eExceedChar                10
  242. #define    eNoPaste                11
  243.  
  244. #define    rMenuBar    128                /* application's menu bar */
  245. #define    rAboutAlert    128                /* about alert */
  246. #define    rUserAlert    129                /* user error alert */
  247. #define    rDocWindow    128                /* application's window */
  248. #define    rVScroll    128                /* vertical scrollbar control */
  249. #define    rHScroll    129                /* horizontal scrollbar control */
  250. #define    kErrStrings    128                /* error string list */
  251.  
  252.  
  253.  
  254. /* defines for the disable/enable flags */
  255. /* use these for easier reading            */
  256.  
  257. #define AllItems    0b1111111111111111111111111111111
  258. #define NoItems        0b0000000000000000000000000000000    
  259. #define MenuItem2    0b0000000000000000000000000000010    
  260. #define MenuItem12    0b0000000000000000000100000000000    
  261.  
  262.